<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head th:replace="fragment/globalComponent::commonHead(~{::title},~{::link},~{::style})">
    <title>GoblinCwl - 基础设置</title>
    <link th:href="@{/css/manager.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/css/goblincwl/tablePage.css}">
    <style>
    </style>
</head>
<body>
<!-- 左侧侧边栏 -->
<div th:replace="fragment/manager/managerComponent::leftSiderBar"></div>

<!-- 页面内容 -->
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <div class="content">
        <!-- 顶部导航 -->
        <div th:replace="fragment/globalComponent::topHeader"></div>

        <div class="col-sm-12" style="padding: 0 10px;padding-top: 1em">
            <ul class="nav nav-tabs" id="navList">
                <li data-name="keyValueOptionsTab" class="active">
                    <a data-toggle="tab" href="#keyValueOptionsTab" onclick="refreshTable('keyValueOptions-table')">
                        键值配置
                    </a>
                </li>
                <li data-name="accessRecordTab" class="">
                    <a data-toggle="tab" href="#accessRecordTab" onclick="refreshTable('accessRecord-table')">
                        访问记录
                    </a>
                </li>
                <li data-name="chatMessageTab" class="">
                    <a data-toggle="tab" href="#chatMessageTab" onclick="refreshTable('chatMessage-table')">
                        聊天消息
                    </a>
                </li>
                <li data-name="ossFileTab" class="">
                    <a data-toggle="tab" href="#ossFileTab" onclick="refreshTable('ossFile-table')">
                        OSS文件
                    </a>
                </li>
            </ul>
            <div class="tab-content" id="tabContent">
                <!--键值对管理-->
                <div id="keyValueOptionsTab" class="tab-pane active">
                    <div class="table-responsive">
                        <div id="keyValueOptions-toolbar" class="btn-group">
                            <button id="keyValueOptions-toolbar-add" type="button"
                                    class="btn btn-success btn-sm rightSize toolbarBtn">
                                <i class="glyphicon glyphicon-plus toolbarIcon" aria-hidden="true"></i>新增
                            </button>
                            <button id=keyValueOptions-toolbar-edit type="button"
                                    class="btn btn-info btn-sm rightSize toolbarBtn">
                                <i class="glyphicon glyphicon-pencil toolbarIcon" aria-hidden="true"></i>修改
                            </button>
                            <button id="keyValueOptions-toolbar-remove" type="button"
                                    class="btn btn-danger btn-sm rightSize toolbarBtn">
                                <i class="glyphicon glyphicon-remove " aria-hidden="true"></i>删除
                            </button>
                        </div>
                        <div class="form-inline table-search">
                            <div class="form-group">
                                <label for="keyValueOptions-query-optKey"></label>
                                <input type="text" class="form-control input-sm"
                                       id="keyValueOptions-query-optKey"
                                       placeholder="键">
                            </div>
                        </div>
                        <table id="keyValueOptions-table" class="table table-condensed text-nowrap my-table"></table>
                    </div>
                </div>

                <!--访问记录-->
                <div id="accessRecordTab" class="tab-pane">
                    <div class="table-responsive">
                        <div id="accessRecord-toolbar" class="btn-group"></div>
                        <div class="form-inline table-search">
                            <div class="form-group">
                                <label for="accessRecord-query-ipAddr"></label>
                                <input type="text" class="form-control input-sm"
                                       id="accessRecord-query-ipAddr"
                                       placeholder="IP地址">
                            </div>
                            <div class="form-group">
                                <label for="accessRecord-query-nickName"></label>
                                <input type="text" class="form-control input-sm"
                                       id="accessRecord-query-nickName"
                                       placeholder="昵称">
                            </div>
                        </div>
                        <table id="accessRecord-table" class="table table-condensed text-nowrap my-table"></table>
                    </div>
                </div>

                <!--聊天消息-->
                <div id="chatMessageTab" class="tab-pane">
                    <div class="table-responsive">
                        <div id="chatMessage-toolbar" class="btn-group">
                            <button id="chatMessage-toolbar-remove" type="button"
                                    class="btn btn-danger btn-sm rightSize toolbarBtn">
                                <i class="glyphicon glyphicon-remove " aria-hidden="true"></i>删除
                            </button>
                        </div>
                        <div class="form-inline table-search">
                            <div class="form-group">
                                <label for="chatMessage-query-content"></label>
                                <input type="text" class="form-control input-sm"
                                       id="chatMessage-query-content"
                                       placeholder="消息内容">
                            </div>
                        </div>
                        <table id="chatMessage-table" class="table table-condensed text-nowrap my-table"></table>
                    </div>
                </div>

                <!--OSS文件-->
                <div id="ossFileTab" class="tab-pane">
                    <div class="table-responsive">
                        <div id="ossFile-toolbar" class="btn-group">
                            <button id="ossFile-toolbar-view" type="button"
                                    class="btn btn-info btn-sm rightSize toolbarBtn">
                                <i class="glyphicon glyphicon-eye-open " aria-hidden="true"></i>预览
                            </button>
                            <button id="ossFile-toolbar-download" type="button"
                                    class="btn btn-primary btn-sm rightSize toolbarBtn">
                                <i class="glyphicon glyphicon-download " aria-hidden="true"></i>下载
                            </button>
                            <button id="ossFile-toolbar-remove" type="button"
                                    class="btn btn-danger btn-sm rightSize toolbarBtn">
                                <i class="glyphicon glyphicon-remove " aria-hidden="true"></i>删除
                            </button>
                        </div>
                        <div class="form-inline table-search">
                            <div class="form-group">
                                <label for="ossFile-query-path"></label>
                                <input type="text" class="form-control input-sm"
                                       id="ossFile-query-path"
                                       placeholder="目录">
                            </div>
                            <div class="form-group">
                                <label for="ossFile-query-originFileName"></label>
                                <input type="text" class="form-control input-sm"
                                       id="ossFile-query-originFileName"
                                       placeholder="原始文件名">
                            </div>
                            <div class="form-group">
                                <label for="ossFile-query-suffix"></label>
                                <input type="text" class="form-control input-sm"
                                       id="ossFile-query-suffix"
                                       placeholder="后缀">
                            </div>
                            <div class="form-group">
                                <label for="ossFile-query-ossFileName"></label>
                                <input type="text" class="form-control input-sm"
                                       id="ossFile-query-ossFileName"
                                       placeholder="OSS文件名">
                            </div>
                        </div>
                        <table id="ossFile-table" class="table table-condensed text-nowrap my-table"></table>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
</body>
<div th:replace="fragment/globalComponent::commonFoot(~{::script})">
    <script th:src="@{/js/goblincwl/tablePage.js}" type="text/javascript"></script>

    <script>
        $(function () {
            //左侧导航
            $("#managerBaseLi").addClass("active")
            initData('keyValueOptionsTab')
            initData('accessRecordTab')
            initData('chatMessageTab')
            initData('ossFileTab')
        })

        //初始化表格
        function initData(name) {
            const tableOptions = genTableOptions();
            let url,                    //请求地址
                columns,                //列
                uniqueId,               //主键
                tableId,              //表格ID
                $table,                 //表格元素
                $toolbar,               //工具栏元素
                $singleBtnArray = [],   //单选按钮
                $multiBtnArray = [],    //多选按钮
                $queryInputArray = [];  //查询框
            switch (name) {
                case 'keyValueOptionsTab':
                    url = ctx + "/manager/keyValueOptions/list";
                    tableId = 'keyValueOptions-table';
                    $table = $("#" + tableId);
                    $toolbar = $("#keyValueOptions-toolbar");
                    uniqueId = "optKey";
                    //单选/多选按钮及事件
                    $("#keyValueOptions-toolbar-add").on('click', function () {
                        keyValueOptionsAdd(tableId);
                    });
                    $singleBtnArray[0] = $("#keyValueOptions-toolbar-edit");
                    $singleBtnArray[0].on('click', function () {
                        keyValueOptionsEdit(tableId)
                    });
                    $multiBtnArray[0] = $("#keyValueOptions-toolbar-remove");
                    $multiBtnArray[0].on('click', function () {
                        keyValueOptionsRemove(tableId)
                    });
                    $queryInputArray[0] = $("#keyValueOptions-query-optKey")
                    //自定义参数
                    tableOptions.queryParams = function (params) {
                        return $.extend(queryParams(params), {
                            optKey: $queryInputArray[0].val()
                        });
                    }
                    columns = [
                        {
                            checkbox: true,
                        },
                        {
                            title: '操作',
                            formatter: function (value, row, index) {//赋予的参数
                                return genTableOptionA('#5bc0de', '修改', 'glyphicon-pencil', 'keyValueOptionsEdit("' + tableId + '",' + JSON.stringify(row) + ')') +
                                    genTableOptionA('#d9534f', '删除', 'glyphicon-remove', 'keyValueOptionsRemove("' + tableId + '","' + row.optKey + '")');

                            }, //自定义方法，添加操作按钮,
                            switchable: false,
                            align: 'center',
                            width: 50,
                            cellStyle: function () {
                                const style = rowStyle(tableOptions);
                                style.css["border-right"] = "1px solid #ddd"
                                return style;
                            },
                        },
                        {
                            field: 'optKey',
                            title: '键',
                            sortable: true,
                            sortName: "opt_key",
                            align: 'center',
                            width: 300,
                            cellStyle: function () {
                                const style = rowStyle(tableOptions);
                                style.css.color = "#337ab7"
                                return style;
                            },
                        },
                        {
                            field: 'optValue',
                            title: '值',
                            align: 'center',
                            width: 300,
                            cellStyle: function () {
                                const style = rowStyle(tableOptions);
                                style.css.color = "green"
                                return style;
                            }
                        }, {
                            field: 'remark',
                            title: '备注'
                        }
                    ];
                    break;
                case 'accessRecordTab':
                    url = ctx + "/manager/accessRecord/list";
                    tableId = "accessRecord-table";
                    $table = $("#" + tableId);
                    $toolbar = $("#accessRecord-toolbar");
                    uniqueId = "id";
                    $queryInputArray[0] = $("#accessRecord-query-ipAddr");
                    $queryInputArray[1] = $("#accessRecord-query-nickName");
                    //自定义参数
                    tableOptions.queryParams = function (params) {
                        return $.extend(queryParams(params), {
                            ipAddress: $queryInputArray[0].val(),
                            nickName: $queryInputArray[1].val(),
                        });
                    };
                    columns = [
                        {
                            field: 'id',
                            title: '主键',
                            sortable: true,
                            align: 'center',
                            width: 50,
                        },
                        {
                            field: 'ipAddress',
                            title: 'IP地址',
                            align: 'center',
                        },
                        {
                            field: 'nickName',
                            title: '昵称',
                            align: 'center',
                        },
                        {
                            field: 'accessTime',
                            title: '访问时间',
                            sortable: true,
                            sortName: 'access_time',
                            align: 'center',
                        },
                        {
                            field: 'lastAccessTime',
                            title: '上次访问时间',
                            sortable: true,
                            sortName: 'last_access_time',
                            align: 'center',
                        },
                        {
                            field: 'accessCount',
                            title: '访问总次数',
                            sortable: true,
                            sortName: 'access_count',
                            align: 'center',
                        },
                    ];
                    break;
                case 'chatMessageTab':
                    url = ctx + "/manager/chatMessage/list";
                    tableId = "chatMessage-table";
                    $table = $("#" + tableId);
                    $toolbar = $("#chatMessage-toolbar");
                    uniqueId = "id";
                    //单选/多选按钮及事件
                    $multiBtnArray[0] = $("#chatMessage-toolbar-remove");
                    $multiBtnArray[0].on('click', function () {
                        chatMessageRemove(tableId)
                    });
                    $queryInputArray[0] = $("#chatMessage-query-content");
                    //自定义参数
                    tableOptions.queryParams = function (params) {
                        return $.extend(queryParams(params), {
                            content: $queryInputArray[0].val(),
                        });
                    };
                    columns = [
                        {
                            checkbox: true,
                        },
                        {
                            title: '操作',
                            formatter: function (value, row, index) {//赋予的参数
                                return genTableOptionA('#c9302c', '删除', 'glyphicon-remove', 'chatMessageRemove("' + tableId + '","' + row.id + '")');
                            }, //自定义方法，添加操作按钮,
                            switchable: false,
                            align: 'center',
                            width: 50,
                            cellStyle: function () {
                                const style = rowStyle(tableOptions);
                                style.css["border-right"] = "1px solid #ddd"
                                return style;
                            },
                        },
                        {
                            field: 'id',
                            title: '主键',
                            width: 50,
                            sortable: true,
                            align: 'center',
                        },
                        {
                            field: 'content',
                            title: '消息内容',
                        },
                        {
                            field: 'sendTime',
                            title: '发送时间',
                            sortable: true,
                            sortName: 'send_time',
                            align: 'center',
                        }
                    ]
                    break;
                case 'ossFileTab':
                    url = ctx + "/manager/ossFile/list";
                    tableId = "ossFile-table";
                    $table = $("#" + tableId);
                    $toolbar = $("#ossFile-toolbar");
                    uniqueId = "ossFileName";
                    // 单选/多选按钮及事件
                    $singleBtnArray[0] = $("#ossFile-toolbar-view");
                    $singleBtnArray[0].on('click', function () {
                        ossFileView(tableId)
                    });
                    $singleBtnArray[1] = $("#ossFile-toolbar-download");
                    $singleBtnArray[1].on('click', function () {
                        ossFileDownload(tableId)
                    });
                    $multiBtnArray[0] = $("#ossFile-toolbar-remove");
                    $multiBtnArray[0].on('click', function () {
                        ossFileRemove(tableId)
                    });
                    $queryInputArray[0] = $("#ossFile-query-path");
                    $queryInputArray[1] = $("#ossFile-query-originFileName");
                    $queryInputArray[2] = $("#ossFile-query-suffix");
                    $queryInputArray[3] = $("#ossFile-query-ossFileName");
                    // 自定义参数
                    tableOptions.queryParams = function (params) {
                        return $.extend(queryParams(params), {
                            path: $queryInputArray[0].val(),
                            originFileName: $queryInputArray[1].val(),
                            suffix: $queryInputArray[2].val(),
                            ossFileName: $queryInputArray[3].val(),
                        });
                    };
                    columns = [
                        {
                            checkbox: true,
                        },
                        {
                            title: '操作',
                            formatter: function (value, row, index) {//赋予的参数
                                return genTableOptionA('#6ecadc', '预览', 'glyphicon-eye-open', 'ossFileView("' + tableId + '","' + (index + 1) + '")') +
                                    genTableOptionA('#337ab7', '下载', 'glyphicon-download', 'ossFileDownload("' + tableId + '",' + JSON.stringify(row) + ')') +
                                    genTableOptionA('#c9302c', '删除', 'glyphicon-remove', 'ossFileRemove("' + tableId + '","' + row.ossFileName + '")') +
                                    "<img src='" + row.fullUrl + "' data-xphoto='imgViewGroup' style='display: none'>"
                                    ;
                            }, //自定义方法，添加操作按钮,
                            switchable: false,
                            align: 'center',
                            width: 50,
                            cellStyle: function () {
                                const style = rowStyle(tableOptions);
                                style.css["border-right"] = "1px solid #ddd"
                                return style;
                            },
                        },
                        {
                            field: 'path',
                            title: '目录',
                            align: 'center',
                        },
                        {
                            field: 'originFileName',
                            title: '原始文件名',
                            align: 'center',
                        },
                        {
                            field: 'suffix',
                            title: '后缀',
                            align: 'center',
                        },
                        {
                            field: 'ossFileName',
                            title: 'OSS文件名',
                            align: 'center',
                        }
                    ]
                    break;
            }


            //渲染表格
            $table.bootstrapTable(pushParamTableOptions(
                tableOptions,
                "GET",
                url,
                columns,
                uniqueId,
                $toolbar,
                $table,
                $singleBtnArray,
                $multiBtnArray,
                $queryInputArray
            ));
            //刷新按钮状态
            $table.bootstrapTable('getOptions').onUncheckAll();
        }


    </script>

    <!--键值配置-->
    <script>
        /*新增*/
        function keyValueOptionsAdd(tableId) {
            const $table = getTable(tableId);
            const winId = xtip.win({
                type: 'confirm',
                btn: ['保存', '取消'],
                icon: ['', '#5cb85c'],
                tip:
                    '<form class="form-horizontal validateForm">\n' +
                    '  <div class="form-group">\n' +
                    '    <label for="keyValueOptions-add-optKey" class="col-sm-2 control-label xtip-label">键</label>' +
                    '    <div class="col-sm-10 xtip-input">' +
                    '      <input type="text" class="form-control input-sm table-modal-input required" ' +
                    '       id="keyValueOptions-add-optKey" placeholder="optKey" oninput="inputValidate($(this))">' +
                    '    </div>' +
                    '  </div>\n' +
                    '  <div class="form-group">\n' +
                    '    <label for="keyValueOptions-add-optValue" class="col-sm-2 control-label xtip-label">值</label>' +
                    '    <div class="col-sm-10 xtip-input">' +
                    '      <input type="text" class="form-control input-sm table-modal-input" ' +
                    '       id="keyValueOptions-add-optValue" placeholder="optValue">' +
                    '    </div>' +
                    '  </div>\n' +
                    '  <div class="form-group">\n' +
                    '    <label for="keyValueOptions-add-remark" class="col-sm-2 control-label xtip-label">备注</label>' +
                    '    <div class="col-sm-10 xtip-input">' +
                    '      <input type="text" class="form-control input-sm table-modal-input" id="keyValueOptions-add-remark" placeholder="remark">' +
                    '    </div>' +
                    '  </div>\n' +
                    '</form>'
                ,
                title: "新增键值对",
                width: '400px',
                maxWidth: '100%',
                shadeClose: false,
                btn1: function () {
                    ajaxHttp({
                        type: "POST",
                        url: ctx + "/manager/keyValueOptions/add",
                        data: {
                            optKey: $("#keyValueOptions-add-optKey").val(),
                            optValue: $("#keyValueOptions-add-optValue").val(),
                            remark: $("#keyValueOptions-add-remark").val()
                        },
                        winId: winId,
                        success: function (res) {
                            xtip.msg(res.msg, {icon: 's', type: 'w'})
                            $table.bootstrapTable('refresh');
                        },
                    })
                }
            });
        }

        /*修改*/
        function keyValueOptionsEdit(tableId, row) {
            const $table = getTable(tableId);
            //获取选择的数据
            if (row == null) {
                //复选框所选数据
                const checkIdList = $table.bootstrapTable('getAllSelections');
                if (checkIdList.length === 1) {
                    row = checkIdList[0];
                } else {
                    xtip.msg("请选择一行数据", {icon: 'e', type: 'w'})
                    return;
                }
            }

            //回显
            ajaxHttp({
                type: "GET",
                url: ctx + "/manager/keyValueOptions/" + row.optKey,
                success: function (res) {
                    const winId = xtip.win({
                        type: 'confirm', //alert 或 confirm
                        btn: ['保存', '取消'],
                        icon: ['', '#5bc0de'],
                        width: '400px',
                        tip:
                            '<form class="form-horizontal validateForm">\n' +
                            '  <div class="form-group">\n' +
                            '    <label for="keyValueOptions-add-optKey" class="col-sm-2 control-label xtip-label">键</label>' +
                            '    <div class="col-sm-10 xtip-input">' +
                            '      <input disabled type="text" class="form-control input-sm table-modal-input required" ' +
                            '       id="keyValueOptions-add-optKey" placeholder="optKey" value="' + res.data.optKey + '" oninput="inputValidate($(this))">' +
                            '    </div>' +
                            '  </div>\n' +
                            '  <div class="form-group">\n' +
                            '    <label for="keyValueOptions-add-optValue" class="col-sm-2 control-label xtip-label">值</label>' +
                            '    <div class="col-sm-10 xtip-input">' +
                            '      <input type="text" class="form-control input-sm table-modal-input" ' +
                            '       id="keyValueOptions-add-optValue" placeholder="optValue" value="' + res.data.optValue + '">' +
                            '    </div>' +
                            '  </div>\n' +
                            '  <div class="form-group">\n' +
                            '    <label for="keyValueOptions-add-remark" class="col-sm-2 control-label xtip-label">备注</label>' +
                            '    <div class="col-sm-10 xtip-input">' +
                            '      <input type="text" class="form-control input-sm table-modal-input" ' +
                            '       id="keyValueOptions-add-remark" placeholder="remark" value="' + res.data.remark + '">' +
                            '    </div>' +
                            '  </div>\n' +
                            '</form>'
                        ,
                        title: "修改键值对",
                        shadeClose: false,
                        btn1: function () {
                            ajaxHttp({
                                type: "PUT",
                                url: ctx + "/manager/keyValueOptions/edit",
                                data: {
                                    optKey: $("#keyValueOptions-add-optKey").val(),
                                    optValue: $("#keyValueOptions-add-optValue").val(),
                                    remark: $("#keyValueOptions-add-remark").val()
                                },
                                winId: winId,
                                success: function (res) {
                                    xtip.msg(res.msg, {icon: 's', type: 'w'})
                                    $table.bootstrapTable('refresh');
                                    $table.bootstrapTable('getOptions').onUncheckAll();
                                },
                            })
                        }
                    });
                },
            })
        }

        /*删除*/
        function keyValueOptionsRemove(tableId, optKey) {
            const $table = getTable(tableId);
            //获取选择的数据
            if (optKey == null) {
                optKey = '';
                //复选框所选数据
                const checkIdList = $("#" + tableId).bootstrapTable('getAllSelections');
                if (checkIdList.length <= 0) {
                    xtip.msg("请选择一行数据", {icon: 'e', type: 'w'})
                    return;
                }
                for (let i = 0; i < checkIdList.length; i++) {
                    let checkIdListElement = checkIdList[i];
                    optKey += checkIdListElement.optKey += ",";
                }
            }
            const winId = xtip.confirm('确认删除所选数据？', function () {
                ajaxHttp({
                    type: "DELETE",
                    url: ctx + "/manager/keyValueOptions/remove",
                    data: {
                        optKeys: optKey
                    },
                    winId: winId,
                    success: function (res) {
                        xtip.msg(res.msg, {icon: 's', type: 'w'})
                        $table.bootstrapTable('refresh');
                        $table.bootstrapTable('getOptions').onUncheckAll();
                    }
                })
            }, {icon: ['', '#d9534f']});
        }
    </script>

    <!--聊天消息-->
    <script>
        /*删除*/
        function chatMessageRemove(tableId, id) {
            const $table = getTable(tableId);
            //获取选择的数据
            if (id == null) {
                id = '';
                //复选框所选数据
                const checkIdList = $table.bootstrapTable('getAllSelections');
                if (checkIdList.length <= 0) {
                    xtip.msg("请选择一行数据", {icon: 'e', type: 'w'})
                    return;
                }
                for (let i = 0; i < checkIdList.length; i++) {
                    let checkIdListElement = checkIdList[i];
                    id += checkIdListElement.id += ",";
                }
            }
            const winId = xtip.confirm('确认删除所选数据？', function () {
                ajaxHttp({
                    type: "DELETE",
                    url: ctx + "/manager/chatMessage/remove",
                    data: {
                        ids: id
                    },
                    winId: winId,
                    success: function (res) {
                        xtip.msg(res.msg, {icon: 's', type: 'w'})
                        $table.bootstrapTable('refresh');
                        $table.bootstrapTable('getOptions').onUncheckAll();

                    }
                })
            }, {icon: ['', '#d9534f']});
        }
    </script>

    <!--OSS文件-->
    <script>
        /*预览*/
        function ossFileView(tableId, index) {
            const $table = getTable(tableId);
            if (index == null) {
                //复选框所选数据
                const checkIdList = $table.bootstrapTable('getAllSelections');
                if (checkIdList.length === 1) {
                    index = (checkIdList[0].index) + 1;
                } else {
                    xtip.msg("请选择一行数据", {icon: 'e', type: 'w'})
                    return;
                }
            }
            xtip.photo("imgViewGroup", {index: index})
        }

        /*删除*/
        function ossFileRemove(tableId, id) {
            const $table = getTable(tableId);
            //获取选择的数据
            if (id == null) {
                id = '';
                //复选框所选数据
                const checkIdList = $table.bootstrapTable('getAllSelections');
                if (checkIdList.length <= 0) {
                    xtip.msg("请选择一行数据", {icon: 'e', type: 'w'})
                    return;
                }
                for (let i = 0; i < checkIdList.length; i++) {
                    let checkIdListElement = checkIdList[i];
                    id += checkIdListElement.ossFileName += ",";
                }
            }
            const winId = xtip.confirm('确认删除所选数据？', function () {
                ajaxHttp({
                    type: "DELETE",
                    url: ctx + "/manager/ossFile/remove",
                    data: {
                        ids: id
                    },
                    winId: winId,
                    success: function (res) {
                        xtip.msg(res.msg, {icon: 's', type: 'w'})
                        $table.bootstrapTable('refresh');
                        $table.bootstrapTable('getOptions').onUncheckAll();

                    }
                })
            }, {icon: ['', '#d9534f']});
        }

        /*下载*/
        function ossFileDownload(tableId, row) {
            const $table = getTable(tableId);

            if (row == null) {
                //复选框所选数据
                const checkIdList = $table.bootstrapTable('getAllSelections');
                if (checkIdList.length === 1) {
                    row = checkIdList[0];
                } else {
                    xtip.msg("请选择一行数据", {icon: 'e', type: 'w'})
                    return;
                }
            }

            const winId = xtip.confirm('确认下载？', function () {
                //使用xhr读取文件流
                const url = ctx + "/manager/ossFile/download?ossFileName=" + row.ossFileName;
                const xhr = new XMLHttpRequest();
                xhr.open('POST', url, true);    // 也可以使用POST方式，根据接口
                xhr.setRequestHeader("Authorization", localStorage.getItem('access_token'));
                xhr.responseType = "blob";  // 返回类型blob
                // 定义请求完成的处理函数，请求前也可以增加加载框/禁用下载按钮逻辑
                xhr.onload = function () {
                    // 请求完成
                    if (this.status === 200) {
                        // 返回200
                        const blob = this.response;
                        const reader = new FileReader();
                        reader.readAsDataURL(blob);  // 转换为base64，可以直接放入a表情href
                        reader.onload = function (e) {
                            // 转换完成，创建一个a标签用于下载
                            const a = document.createElement('a');
                            a.download = row.originFileName;
                            a.href = e.target.result;
                            $("body").append(a);  // 修复firefox中无法触发click
                            a.click();
                            $(a).remove();
                            //关闭确认框
                            xtip.close(winId)
                        }
                    }
                };
                // 发送ajax请求
                xhr.send()
            }, {icon: ['', '#337ab7']});
        }
    </script>
</div>
</html>